﻿
/// <reference path="base/framwork.js" />
/// <reference path="widget/iscroll.js" />
/// <reference path="base/jquery.js" />
/// <reference path="base/transit.js" />

$(document).ready(function () {
    var loadBox = $('aside.loadBox');
    var articleBox = $('article');
    icom.orient(init);

    function init() {
        //loadBox.show();
        //iuser.init(userGetted);
        load_handler();
    }

    function userGetted(data) {
        console.log('用户头像：' + data.headimage);
        console.log('用户昵称：' + data.nickname);
        load_handler();
    }

    function load_handler() {
        var loader = new PxLoader();
        loader.addImage('images/obg.jpg');
        //实际加载进度
        loader.addProgressListener(function (e) {
            var per = Math.round(e.completedCount / e.totalCount * 50);
            //loadPer.html(per + '%');
        });
        loader.addCompletionListener(function () {
            init_handler();
            loader = null;
        });
        loader.start();
    }


    function init_handler() {
        console.log('init handler');
        monitor_handler();

        var list = $('.list');

        $.get('/webajax/GetGongde.ashx', function (data) {
            $.each(data, function (i, item) {
                list.append("<div class='item'><img src='/upload/gd/" + item.Photo + "' /><div>" + item.Title + "</div><a class='btn' val='" + item.Attachment + "' data-id='" + item.ID + "'>" + item.Attachment + "元</a></div>");
                $('.btn').on('click', function () {
                    var obj = $('#txt_Amount');
                    obj.val($(this).attr('val'));
                    obj.attr('data-type-id', $(this).attr('data-id'));
                })
            });
        }, 'json');


        $("footer").load("/module/foot.html");


        $('.btn_random').on('click', function () {
            var obj = $('#txt_Amount');
            obj.val((imath.randomRange(100, 1000) / 100).toFixed(2));
            obj.attr('data-type-id', '-1');
        })

        $('.btn_donate').on('touchend', MeritsPay);
    }

    //----------------------------------------页面监测代码----------------------------------------
    function monitor_handler() {
        //imonitor.add({obj:$('a.btnTest'),action:'touchstart',category:'首页',label:'测试按钮'});
    }

});

